package com.cskaoyan.controller.lz_controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.lzpackage.lz_config.ConfigData;
import com.cskaoyan.bean.lzpackage.lz_config.ConfigMall;
import com.cskaoyan.mapper.ElseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("admin/config")
public class AdminConfigMallController {
  @Autowired
    ElseMapper elseMapper;
    @GetMapping("mall")
    public BaseRespVo list() {
         String address= elseMapper.selectMsg("market_mall_address");
        String latitude= elseMapper.selectMsg("market_mall_latitude");
        String longitude= elseMapper.selectMsg("market_mall_longitude");
        String name= elseMapper.selectMsg("market_mall_name");
        String phone= elseMapper.selectMsg("market_mall_phone");
        String qq= elseMapper.selectMsg("market_mall_qq");
        ConfigMall configMall=new ConfigMall();
      configMall.setMarket_mall_address(address);
      configMall.setMarket_mall_latitude(latitude);
      configMall.setMarket_mall_longitude(longitude);
      configMall.setMarket_mall_name(name);
      configMall.setMarket_mall_phone(phone);
      configMall.setMarket_mall_qq(qq);
        return BaseRespVo.ok(configMall);
    }
    @PostMapping("mall")
    public BaseRespVo list1(@RequestBody ConfigMall configMall) {
        elseMapper.updateMsg(configMall.getMarket_mall_address(),"market_mall_address");
        elseMapper.updateMsg(configMall.getMarket_mall_latitude(),"market_mall_latitude");
        elseMapper.updateMsg(configMall.getMarket_mall_name(),"market_mall_name");
        elseMapper.updateMsg(configMall.getMarket_mall_phone(),"market_mall_phone");
        elseMapper.updateMsg(configMall.getMarket_mall_qq(),"market_mall_qq");
        elseMapper.updateMsg(configMall.getMarket_mall_longitude(),"market_mall_longitude");
        return BaseRespVo.out();
    }
}
